﻿using System.Globalization;
using System.Windows.Data;

namespace Super.Hmi.Converters
{
    /// <summary>
    /// 转换器，用于判断抽屉是否打开
    /// </summary>
    public class DrawerIsOpenConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            return values.OfType<bool>().Any(b => b);
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            if (value is bool isOpen && !isOpen)
            {
                return Enumerable.Repeat((object)false, targetTypes.Length).ToArray();
            }
            return null;
        }
    }
}
